export default{
    get(url){
        var xmlhttp;
        var data = {};
        if (window.XMLHttpRequest){
            //  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
            xmlhttp=new XMLHttpRequest();
        }else
        {
            // IE6, IE5 浏览器执行代码
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.open('get',url,false);
        xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
        // 4.监听状态的变化
        xmlhttp.onreadystatechange = function () {
            if(xmlhttp.readyState === 4){
                if(xmlhttp.status >= 200 && xmlhttp.status < 300 ||
                    xmlhttp.status === 304){
                    data = {
                        data:JSON.parse(xmlhttp.responseText),
                        status:xmlhttp.status
                    } 
                }else{
                    data = {
                        data:JSON.parse(xmlhttp.responseText),
                        status:xmlhttp.status
                    }
                }
            }
        }
        xmlhttp.send();
        return data;
    },
    putFontcss(url){
        let link = document.createElement('link');
        link.rel = 'stylesheet';
        link.href = url;
        document.querySelector('head').appendChild(link);
    },
    putfontJs(url){
        let script = document.createElement('script');
        script.src = url;
        document.querySelector('head').appendChild(script);
    },
    putArcgisCss(arr,url){
        let href = window.location;
        let pathname = href.pathname;
        let a = pathname.lastIndexOf('/');
        let name = pathname.substr(a+1);
        let nameArr = name.split('.');
        let pageName = nameArr[0];
        let myArr = arr.filter(function(item){
            return item == pageName
        });
        if(myArr.length > 0){
            let link = document.createElement('link');
            link.rel = 'stylesheet';
            link.href = url;
            document.querySelector('head').appendChild(link);
        }
    }
}